#define _CRT_SECURE_NO_WARNINGS 1
int maxArea(int* height, int heightSize) {
    int left = 0;
    int right = heightSize - 1;
    int h = 0;
    int sum = 0;
    int tmp = 0;
    int flag = 0;
    while (left < right) {
        if (height[left] <= height[right]) {
            h = height[left];
            flag = 0;
        }
        else {
            h = height[right];
            flag = 1;
        }
        tmp = (right - left) * h;
        if (tmp > sum) {
            sum = tmp;
        }
        if (flag == 0)
            left++;
        else
            right--;
    }
    return sum;
}